home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmMain
- BorderStyle = 3 'Fixed Dialog
- Caption = "Registry Example #4"
- ClientHeight = 3000
- ClientLeft = 10005
- ClientTop = 6675
- ClientWidth = 3720
- Icon = "frmMain.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 3000
- ScaleWidth = 3720
- StartUpPosition = 1 'CenterOwner
- Begin VB.CommandButton cmdQueryValue
- Caption = "&Query Value"
- Height = 375
- Left = 2160
- TabIndex = 11
- Top = 2520
- Width = 1455
- End
- Begin VB.CommandButton cmdSetValue
- Caption = "&Set Value"
- Height = 375
- Left = 120
- TabIndex = 10
- Top = 2520
- Width = 1455
- End
- Begin VB.ComboBox cboBaseHkey
- Height = 315
- ItemData = "frmMain.frx":0442
- Left = 1560
- List = "frmMain.frx":0444
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 600
- Width = 2055
- End
- Begin VB.TextBox txtValue
- Height = 285
- Left = 1560
- TabIndex = 9
- Top = 2040
- Width = 2055
- End
- Begin VB.TextBox txtValueName
- Height = 285
- Left = 1560
- TabIndex = 7
- Top = 1560
- Width = 2055
- End
- Begin VB.TextBox txtKeyName
- Height = 285
- Left = 1560
- TabIndex = 5
- Top = 1080
- Width = 2055
- End
- Begin VB.TextBox txtComputerName
- Height = 285
- Left = 1560
- TabIndex = 1
- Top = 120
- Width = 2055
- End
- Begin VB.Label Label6
- Caption = "Value:"
- Height = 255
- Left = 120
- TabIndex = 8
- Top = 2040
- Width = 1215
- End
- Begin VB.Label Label4
- Caption = "Value Name:"
- Height = 255
- Left = 120
- TabIndex = 6
- Top = 1560
- Width = 1215
- End
- Begin VB.Label Label3
- Caption = "Key Name:"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 1080
- Width = 1215
- End
- Begin VB.Label Label2
- Caption = "Base HKEY:"
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 600
- Width = 1215
- End
- Begin VB.Label Label1
- Caption = "Computer Name:"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1215
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '****************************************************************************************************
- ' Copyright (c) Key Technology Pty Ltd 1998-1999, All Rights Reserved.
- ' Web site: http://www.keytech.com.au Email: info@keytech.com.au
- '****************************************************************************************************
- Option Explicit
- Private Reg As New RegistryAccessor
- Private Sub cmdQueryValue_Click()
- On Error Resume Next
- ' Get the value
- Dim Value As Variant
- With Reg
- .ComputerName = txtComputerName.Text
- .HKEY = cboBaseHkey.ItemData(cboBaseHkey.ListIndex)
- .SubKey = txtKeyName.Text
- .ValueName = txtValueName.Text
-
- Value = .Value
- End With
- If Err.Number <> 0 Then
- MsgBox "Failed to query value - " & _
- Err.Description & " (" & Hex(Err.Number) & ")"
- Err.Clear
- Exit Sub
- End If
- ' Display the value
- txtValue.Text = Value
- End Sub
- Private Sub cmdSetValue_Click()
- On Error Resume Next
- ' Set the value
- With Reg
- .ComputerName = txtComputerName.Text
- .HKEY = cboBaseHkey.ItemData(cboBaseHkey.ListIndex)
- .SubKey = txtKeyName.Text
- .ValueName = txtValueName.Text
-
- .Value = txtValue.Text
- End With
- If Err.Number <> 0 Then
- MsgBox "Failed to set value - " & _
- Err.Description & " (" & Hex(Err.Number) & ")"
- Err.Clear
- Exit Sub
- End If
- End Sub
- Private Sub Form_Load()
- ' Initialize the base HKEY combo
- cboBaseHkey.AddItem "LOCAL_MACHINE"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_LOCAL_MACHINE
- cboBaseHkey.AddItem "CLASSES_ROOT"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_CLASSES_ROOT
- cboBaseHkey.AddItem "CURRENT_CONFIG"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_CURRENT_CONFIG
- cboBaseHkey.AddItem "CURRENT_USER"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_CURRENT_USER
- cboBaseHkey.AddItem "DYN_DATA"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_DYN_DATA
- cboBaseHkey.AddItem "PERF_DATA"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_PERFORMANCE_DATA
- cboBaseHkey.AddItem "USERS"
- cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_USERS
- cboBaseHkey.ListIndex = 0
- End Sub
-